package cn.software.service.impl;

import cn.software.ex.NullContentException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.software.entity.Notes;
import cn.software.service.NotesService;
import cn.software.mapper.NotesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 眉眼如初
* @description 针对表【notes(笔记)】的数据库操作Service实现
* @createDate 2023-06-05 10:25:57
*/
@Service
public class NotesServiceImpl extends ServiceImpl<NotesMapper, Notes>
    implements NotesService{

    @Autowired
    NotesMapper notesMapper;

    @Override
    public List<Notes> selectNotesListByTopic(int topicId,int stuId) {
        QueryWrapper<Notes> qw = new QueryWrapper<>();
        qw.eq("topic_id",topicId);
        qw.eq("stu_id",stuId);
        List<Notes> notesList = notesMapper.selectList(qw);

        if(notesList == null) {
            throw new NullContentException("该题目下无笔记");
        }
        return notesList;

    }
}




